﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UITesting;
using BackOffice.Context.UltiPro.BackOfficeUIMapClasses;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Windows.Input;
using BackOffice.Context.UltiPro.PageObjects;

namespace BackOffice.Context.UltiPro.Macros
{
    /// <summary>
    /// Pay Data Entry macros
    /// </summary>
    public class PayDataEntryMacros
    {
        /// <summary>
        /// Gets the UI map.
        /// </summary>
        /// <value>
        /// The UI map.
        /// </value>
        private static BackOfficeUIMap UIMap
        {
            get
            {
                return new BackOfficeUIMap();
            }
        }

        /// <summary>
        /// The screen name
        /// </summary>
        private const string ScreenName = "PDE";

        /// <summary>
        /// Edits the earning amount.
        /// </summary>
        /// <param name="rowNum">The row number.</param>
        /// <param name="earnAmount">The earn amount.</param>
        public static void EditEarningAmount(int rowNum, string earnAmount)
        {
            Mouse.Click(PayDataEntry.EarningsGrid, MouseButtons.Right);
            Mouse.Click(UIMap.UIPDEContextMenu.UIPDEGridContextMenu.UIEditRecordMenuItem);
            Keyboard.SendKeys("{SPACE}");
            UIMap.UIULTIPROWindow.UICodeSetupWindow.UIItemWindow27.UIGridCell.WaitForControlEnabled();
            Keyboard.SendKeys(earnAmount);
            Keyboard.SendKeys("{TAB}");
        }

        /// <summary>
        /// Clicks the super finder.
        /// </summary>
        public static void ClickSuperFinder()
        {
            UIMacros.ClickSuperFinder(ScreenName);
        }

        /// <summary>
        /// Employees the finder by empno.
        /// </summary>
        /// <param name="empNo">The emp no.</param>
        public static void EmployeeFinderByEmpno(string empNo)
        {
            UIMacros.EmployeeFinderByEmpno(PayDataEntry.SuperFinderWindow, empNo);
        }

        /// <summary>
        /// Calculates the check.
        /// </summary>
        public static void CalculateCheck()
        {
            Mouse.Click(new Point(Helpers.ScaledXPosition(1635), 141));
        }
    }
}
